package hiho.ku._1135;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int z = in.nextInt();
		String s = in.next();
		int a = 0;
		int b = 0;
		int c = 0;
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			char now = s.charAt(i);
			if (now == 'R')
				a++;
			else if (now == 'B')
				b++;
			else
				c++;
			if (check(a, b, c, x, y, z) || check(a, c, b, x, y, z) || check(b, a, c, x, y, z) || check(b, c, a, x, y, z) || check(c, a, b, x, y, z) || check(c, b, a, x, y, z)) {
				ans = Math.max(a + b + c, ans);
				a = 0;
				b = 0;
				c = 0;
			}
		}
		ans = Math.max(a + b + c, ans);
		System.out.println(ans);
	}
	
	private static boolean check(int a, int b, int c, int x, int y, int z) {
		return Math.abs(a - b) == x && Math.abs(b - c) == y && Math.abs(a - c) == z;
	}

}
